/*
 * @FilePath: \bridge_web\src\main.js
 * @Author: bsj
 * @Date: 2023-09-27 15:45:30
 * @LastEditTime: 2024-04-07
 * @LastEditors: baoshijie
 * @Description: 
 */
import { createApp } from 'vue'
import request from '@/utils/request'
import Cookies from 'js-cookie'
// import 'default-passive-events'
import ElementPlus from 'element-plus'
import locale from 'element-plus/es/locale/lang/zh-cn' // 中文语言
import '@/assets/styles/index.scss' // global css

import App from './App'
import store from './store'
import router from './router'
import directive from './directive' // directive


// 注册指令
import plugins from './plugins' // plugins
import { downloadGetBlob ,downloadGet } from '@/utils/request'

// svg图标
import 'virtual:svg-icons-register'
import SvgIcon from '@/components/SvgIcon'
import elementIcons from '@/components/SvgIcon/svgicon'

import './permission' // permission control


import { parseTime, resetForm, addDateRange, handleTree, selectDictLabel } from '@/utils/notam'

// 分页组件
import Pagination from '@/components/Pagination'
// 自定义树选择组件
import TreeSelect from '@/components/TreeSelect'

import MultipleSelectAll from '@/components/MultipleSelectAll'
const app = createApp(App)

// 全局方法挂载
app.config.globalProperties.downloadGetBlob = downloadGetBlob
app.config.globalProperties.downloadGet = downloadGet

app.config.globalProperties.parseTime = parseTime
app.config.globalProperties.resetForm = resetForm
app.config.globalProperties.handleTree = handleTree
app.config.globalProperties.addDateRange = addDateRange
app.config.globalProperties.selectDictLabel = selectDictLabel

// 全局组件挂载
app.component('Pagination', Pagination)
app.component('TreeSelect', TreeSelect)
app.component('MultipleSelectAll', MultipleSelectAll)

app.use(router)
app.use(store)
app.use(plugins)
app.use(elementIcons)
app.component('svg-icon', SvgIcon)

//将请求方法添加到VuePrototype中
const VuePrototype = app.config.globalProperties
VuePrototype.request = request
directive(app)

// 使用element-plus 并且设置全局的大小
app.use(ElementPlus, {
  locale: locale,
  // 支持 large、default、small
  size: Cookies.get('size') || 'default'
})

app.mount('#app')
